﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web.View.messagesMenu.Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>messages</title>
    <script src="/View/js/Alert.js" type="text/javascript"></script> 
    <script type="text/javascript">
        function SetWinData(index) {
            document.getElementById("Hid").value = messages_MainStore.getAt(index).get('id');
            document.getElementById("MessageFrom").value = messages_MainStore.getAt(index).get('fromun');
			//TxtNumfromun.setValue(messages_MainStore.getAt(index).get('fromun'));
			//TxtNumtoun.setValue(messages_MainStore.getAt(index).get('toun'));
			//Txtdetail.setValue(messages_MainStore.getAt(index).get('detail'));
			//Txtifread.setValue(messages_MainStore.getAt(index).get('ifread'));
            //Txttime.setValue(messages_MainStore.getAt(index).get('time'));

            
			Txtdetail.setValue(messages_MainStore.getAt(index).get('detail'));
			//Txttime.setValue(messages_MainStore.getAt(index).get('time'));
            Sender_Name.setValue(messages_MainStore.getAt(index).get('sender'));
            Send_Time.setValue(messages_MainStore.getAt(index).get('time'));
            Detail.setValue(messages_MainStore.getAt(index).get('detail'));
            messages_Detail.show();
        }
    </script>
</head>
<body>
    <form id="MainForm" runat="server">
    <ext:ResourceManager ID="MainResourceMgr" runat="server" />
    <!--用来导出到Excel的数据源-->
    <ext:Hidden ID="ExcelGridData" runat="server" />
    <!--messages表页面主数据元，自动生成-->
    <ext:Store runat="server" ID="messages_MainStore" OnRefreshData="messages_DataBind" AutoLoad="true">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="id">
                <Fields>
                    
					<ext:RecordField Name="id" />
					<ext:RecordField Name="fromun" />
					<ext:RecordField Name="toun" />
					<ext:RecordField Name="detail" />
					<ext:RecordField Name="ifread" />
					<ext:RecordField Name="time" />
                    <ext:RecordField Name="sender" />

                </Fields>
            </ext:JsonReader>
        </Reader> 
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw">
            </ext:Parameter>
            <ext:Parameter Name="limit" Value="15" Mode="Raw">
            </ext:Parameter>
        </BaseParams>
    </ext:Store>
    <ext:Store runat="server" ID="message_DialogStore" OnRefreshData="messages_DataBind2" AutoLoad="true" >
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="userid">
                <Fields>                    
					<ext:RecordField Name="userid" />
					<ext:RecordField Name="username" />
					<ext:RecordField Name="password" />
					<ext:RecordField Name="roleid" />
					<ext:RecordField Name="telephone" />
					<ext:RecordField Name="usersex" />
                    <ext:RecordField Name="address" />
                    <ext:RecordField Name="email" />
                    <ext:RecordField Name="logintime" />
                    <ext:RecordField Name="createtime" />
                </Fields>
            </ext:JsonReader>
        </Reader> 
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw">
            </ext:Parameter>
            <ext:Parameter Name="limit" Value="7" Mode="Raw">
            </ext:Parameter>
        </BaseParams>
    </ext:Store>
    <!--messages页面主表格-->
    <ext:Viewport ID="MainViewPort" runat="server">
        <Items>
            <ext:FitLayout>
                <Items>
                    <ext:GridPanel ID="messages_Grid" Layout="fit" TrackMouseOver="true" runat="server" StoreID="messages_MainStore"
                        StripeRows="true" Header="false" Border="false" Collapsible="true">
                        <TopBar>
                            <ext:Toolbar ID="MainToolBar" runat="server">
                                <Items>
                                    <ext:Button ID="BtnAdd" runat="server" Text="发送消息" Icon="Add">
                                        <DirectEvents>
                                            <Click OnEvent="BtnAdd_Click">
                                                <EventMask ShowMask="true"   />
                                            </Click>
                                         </DirectEvents>
                                        <Listeners>
                                            <Click Handler="#{messages_MainForm}.getForm().reset();#{Hid}.setValue('');#{messages_Win}.show();" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button ID="BtnDel" runat="server" Text="删除" Icon="Delete">
                                        <DirectEvents>
                                            <Click OnEvent="BtnDel_Click">
                                                <Confirmation ConfirmRequest="true" Title="确认" Message="确实要删除吗?" />
                                                <EventMask ShowMask="true" Msg="正在删除数据，请等候 ..." />
                                            </Click>
                                        </DirectEvents>
                                        <Listeners>
                                            <Click Handler="if(#{messages_Grid}.getSelectionModel().getCount()<=0) {TellAlert('请选择要删除的记录');return false;}" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:ToolbarSeparator />
                                    <ext:Button ID="BtnReload" runat="server" Text="重新加载" Icon="Reload">
                                        <Listeners>
                                            <Click Handler="#{messages_MainStore}.reload();" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:ToolbarFill />
                                    <ext:Button ID="BtnToExcel" runat="server" Text="To Excel" AutoPostBack="true" OnClick="BtnSaveToExcel"
                                        Icon="PageExcel">
                                        <Listeners>
                                            <Click Handler="#{ExcelGridData}.setValue(Ext.encode(messages_Grid.getRowsValues(false)));" />
                                        </Listeners>
                                        <ToolTips>
                                            <ext:ToolTip Title="将当前页内容存储为Excel文件">
                                            </ext:ToolTip>
                                        </ToolTips>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <ColumnModel ID="messages_ColumnMode" runat="server">
                            <Columns>
                                <ext:RowNumbererColumn Width="20" />
                                <ext:Column Header="主键" Sortable="true" Hidden="true" DataIndex="id" />   
								<ext:Column Header="fromun" Sortable="true" Hidden="true" DataIndex="fromun" />
								<ext:Column Header="toun" Sortable="true" Hidden="true" DataIndex="toun" />
                                <ext:Column Header="发件人" Sortable="true" DataIndex="sender" />
								<ext:Column Header="详细信息" Sortable="true" DataIndex="detail" />
								<ext:Column Header="ifread" Sortable="true" Hidden="true" DataIndex="ifread" />
								<ext:Column Header="时间" Sortable="true" DataIndex="time" />
                     
                            </Columns>
                        </ColumnModel>
                        <Listeners>
                            <RowDblClick Handler="SetWinData(rowIndex);" />
                        </Listeners>
                        <Plugins>
                            <ext:GridFilters runat="server" FiltersText="查找" ID="messages_Filter">
                                <Filters>
                                    
								<ext:StringFilter DataIndex="detail" />
								<ext:StringFilter DataIndex="ifread" />
								<ext:StringFilter DataIndex="time" />

                                </Filters>
                            </ext:GridFilters>
                        </Plugins>
                        <LoadMask ShowMask="true" Msg="正在加载..." />
                        <SelectionModel>
                            <ext:CheckboxSelectionModel  ID="CheckBoxGrid" runat="server" />
                        </SelectionModel>
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolBar" StoreID="messages_MainStore" PageSize="15" runat="server" />
                        </BottomBar>
                    </ext:GridPanel>
                </Items>
            </ext:FitLayout>
        </Items>
    </ext:Viewport>
    <!--messages表修改，添加主窗体-->
    <ext:Window ID="messages_Win" Collapsible="true" Hidden="true" Modal="true"
        Maximizable="true" runat="server" Title="添加/修改记录" Icon="WorldEdit" Width="600"  Height="300"
        Resizable="true">
        <Items>
            <ext:Hidden ID="Hid" runat="server">
            </ext:Hidden>
            <ext:Hidden ID="MessageFrom" runat="server">
            </ext:Hidden>
            <ext:FormPanel ID="messages_MainForm" LabelWidth="65" Frame="true" runat="server"
                Border="false" Height="300" Padding="5" Icon="UserAdd" Layout="Column">
                <Items>
                    <ext:Panel runat="server" Border="false" Header="false" ColumnWidth=".5" Layout="Form" Width = "300" Height="250">
                        <Items>	
                           	<ext:GridPanel ID="send_Grid"  AnchorHorizontal="92%" Layout="fit" TrackMouseOver="true" runat="server" StoreID="message_DialogStore" Height ="200" Width="250"
                        StripeRows="true" Header="false" Border="false" Collapsible="true" AutoWidth="true" > 
                                 <ColumnModel  runat="server">
                                    <Columns>
                                         <ext:RowNumbererColumn   Width="20" />
                                        <ext:Column Header="Name"  Sortable="true" DataIndex="username" Width="103"   />  
                                        <ext:Column Header="telephone" Sortable="true" Width="105" DataIndex="telephone" />
                                    </Columns>
                                </ColumnModel>
                                <Plugins>
                                    <ext:GridFilters runat="server" FiltersText="找" ID="GridFilters1">
                                        <Filters>                                    
								            <ext:StringFilter DataIndex="username" />
                                        </Filters>
                                    </ext:GridFilters>
                                </Plugins>	
                                <SelectionModel>
                                    <ext:CheckboxSelectionModel ID="CheckboxSelection1" runat="server"  />
                                </SelectionModel>
                                <BottomBar>
                                     <ext:PagingToolbar ID="PagingToolBar1" StoreID="message_DialogStore" PageSize="7" runat="server" DisplayInfo="false" />
                                </BottomBar>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                    <ext:Panel runat="server" Border="false" Header="false" ColumnWidth=".5" Layout="Form" Height="250">
                        <Items>     
                            <ext:TextArea ID="Txtdetail" Height ="200" AnchorHorizontal="92%" runat="server" AllowBlank="false" EmptyText="该项不可为空" FieldLabel="detail" />	 
                                            													
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons> 
            <ext:Button Text="提交" ID="BtnSave" runat="server" Icon="Disk">
                <DirectEvents>
                    <Click OnEvent="BtnSave_Click">
                        <EventMask ShowMask="true" Msg="正在提交，请等候 ..."  />
                    </Click>
                </DirectEvents>
                <Listeners>
                    <Click Handler="if (#{messages_MainForm}.getForm().isValid()) {;}else{Ext.Msg.show({icon: Ext.MessageBox.ERROR, msg: '您填写的信息不正确，请您确认！', buttons:Ext.Msg.OK});return false;}" />
                </Listeners>
            </ext:Button>
            <ext:Button Text="取消" ID="BtnConcel" Icon="Delete">
                <Listeners>
                    <Click Handler="#{messages_Win}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <ext:Window ID="messages_Detail" Collapsible="true" Hidden="true" Modal="true"
        Maximizable="true" runat="server" Title="消息详情" Icon="WorldEdit"  Width="500" AutoHeight="true"
        Resizable="true">
        
        <Items>
            <ext:Hidden ID="Hidd" runat="server">
            </ext:Hidden>
            <ext:TextField ID="Sender_Name" ReadOnly="true" AnchorHorizontal="92%" runat="server" AllowBlank="false" Width="300" FieldLabel="发件人" />
            <ext:TextField ID="Send_Time" ReadOnly="true" AnchorHorizontal="92%" runat="server" AllowBlank="false" Width="300" FieldLabel="发送时间" />
            <ext:TextArea ID="Detail" ReadOnly="true" AnchorHorizontal="92%" runat="server" AllowBlank="false" Width="300" AutoHeight="true" FieldLabel="详细消息" /> 
        </Items>
        <Buttons>  
            <ext:Button Text="快速回复" ID="BtnResponse" runat="server" Icon="Disk" >
                <DirectEvents>
                    <Click OnEvent="BtnResponse_Click"/>
                </DirectEvents>     
                <Listeners>
                    <Click Handler="#{Hid}.setValue('')" />
                </Listeners>           
            </ext:Button>
            <ext:Button Text="关闭" ID="BtnClose" Icon="Delete">
                <Listeners>
                    <Click Handler="#{messages_Detail}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    </form>
</body>
</html>
